<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Insert title here</title>
<jsp:include page="base/jscss.jsp"></jsp:include>
</head>
<body>
 <h2>Book Store</h2>
    <p>Fill the form to login.</p>
    <div style="margin:20px 0;"></div>
    <div class="easyui-panel" title="Login the book store" style="width:400px">
        <div style="padding:10px 60px 20px 60px">
	        <form id="ff" method="post" action = "login">
	            <table cellpadding="5">
	                <tr>
	                    <td>Account:</td>
	                    <td><input class="easyui-textbox" type="text" name="client.account" data-options="required:true"></input></td>
	                </tr>
	                <tr>
	                    <td>Password:</td>
	                    <td><input class="easyui-textbox" type="password" name="client.pwd" data-options="required:true"></input></td>
	                </tr>
	            </table>
	        </form>
	        <div style="text-align:center;padding:5px">
	            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="submitForm()">Login</a>
	            <a href="javascript:void(0)" class="easyui-linkbutton" onclick="registerForm()">Register</a>
	        </div>
	        <!-- <div id="toolbar">
		        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-add" plain="true" onclick="newUser()">New User</a>
		        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-edit" plain="true" onclick="editUser()">Edit User</a>
		        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-remove" plain="true" onclick="destroyUser()">Remove User</a>
		    </div> -->
        </div>
    </div>
    
    <!-- 下面这个div是加进来想做register的弹出框 -->
    
    <div id="dlg" class="easyui-dialog" style="width:400px;height:280px;padding:10px 20px"
            closed="true" buttons="#dlg-buttons">
        <div class="ftitle">User Information</div>
        <form id="fm" method="post" action = "register">
            <div class="fitem">
            <table>
	            <tr>
	                <td><label>Account:</label></td>
	                <td><input name="client.account" class="easyui-textbox" required="true"></td>
	            </tr>
	            <tr>
	                <td><label>Password:</label></td>
	                <td><input name="client.pwd" type="password" class="easyui-textbox" required="true"></td>
	            </tr>
	            <tr>
	                <td><label>Nick Name:</label></td>
	                <td><input name="client.clientName" class="easyui-textbox"></td>
	            </tr>
	            <tr>
	                <td><label>Recharge:</label></td>
	                <td><input name="client.balance" class="easyui-textbox"></td>
	            </tr>
	        </table>
            </div>
        </form>
    </div>
    
    <!-- 这个div是弹出框的两个button -->
    
    <div id="dlg-buttons">
        <a href="javascript:void(0)" class="easyui-linkbutton c6" iconCls="icon-ok" onclick="registerClient()" style="width:90px">Register</a>
        <a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-cancel" onclick="javascript:$('#dlg').dialog('close')" style="width:90px">Cancel</a>
    </div>
    
    <!-- 下面这个script是实现弹出框功能的 -->
    
        <script type="text/javascript">
        var url;
        function registerForm(){
            $('#dlg').dialog('open').dialog('setTitle','Register');
            $('#fm').form('clear');
        }
        function submitForm(){
        	$('#ff').submit()
           /*  var row = $('#dg').datagrid('getSelected');
            if (row){
                $('#dlg').dialog('open').dialog('setTitle','Edit User');
                $('#fm').form('load',row);
                url = 'update_user.php?id='+row.id;
            } */
        }
        function registerClient(){
        	$('#fm').submit()
            /* $('#fm').form('submit',{
                url: url,
                onSubmit: function(){
                    return $(this).form('validate');
                },
                success: function(result){
                    var result = eval('('+result+')');
                    if (result.errorMsg){
                        $.messager.show({
                            title: 'Error',
                            msg: result.errorMsg
                        });
                    } else {
                        $('#dlg').dialog('close');        // close the dialog
                        $('#dg').datagrid('reload');    // reload the user data
                    }
                }
            }); */
        }
    </script>
</body>
</html>